<template>
  <div>
    <div class="rocomd">
      <div class="Listcontent">
        <div class="rocomd-min" 
          v-for="item in items"
          :key='item.id'
          @click="clickItem( item.id )"
        >
          <img v-lazy="item.pic" alt="">
          <p>{{ item.name }}</p>
          <div class="shopadd">
            <span class="price">{{ item.minPrice | filter }}</span>
            <van-icon @click.stop="addCar(item)" name="add"/>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  filters: {
    filter (v, sine="￥") {
      return sine + v
    }
  },
  props: {
    items: {
      type: Array,
      required: true
    }
  },
  methods: {
    clickItem (id) {
      this.$emit('click', id)
    },
    addCar (item) {
      console.log(item);
      this.$emit('addcarCat', item)
    }
  }
}
</script>

<style lang="scss" scoped>
.rocomd{
  margin-top: 100px;
  margin-bottom: 100px;
}
  .Listcontent{
      display: flex;
      justify-content: space-around;
      flex-wrap: wrap;
      position: absolute;
      left: 0;
    .rocomd-min{
      height: 311px;
      width: 45%;
      p{
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .shopadd{
        display: flex;
        justify-content: space-around;
        font-size: 20px;
        color: red;
      }
      img{
        height: 187px;
        width: 100%;
      }
    }
  }
</style>
